package com.pojo.entity;

import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.pojo.parent.BaseEntity;
import com.utility.constant.MessageConstant;
import com.utility.constant.RegularConstant;
import com.utility.gruops.InsertAndUpdateGroups;
import com.utility.gruops.InsertGroup;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.hibernate.validator.constraints.Length;

import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;

/**
 * <p>
 * 系统用户表
 * </p>
 *
 * @author hewei
 * @since 2020-11-26
 */
@Data
@EqualsAndHashCode(callSuper = true)
@TableName("system_user")
public class SystemUserEntity extends BaseEntity {



    /**
     * 用户名
     */
    @NotNull(groups = InsertAndUpdateGroups.class,
            message = "用户名"+ MessageConstant.NULL_MESSAGE)
    @Length(groups = InsertAndUpdateGroups.class,
            min = 1,
            max = 128,
            message =  "用户名"+ MessageConstant.LENGTH_MESSAGE_128)
    private String userName;

    /**
     * 密码
     */
    @NotNull(groups = InsertGroup.class,
            message = "密码"+ MessageConstant.NULL_MESSAGE)
    @Length(groups = InsertAndUpdateGroups.class,
            min = 1,
            max = 128,
            message =  "密码"+ MessageConstant.LENGTH_MESSAGE_128)

    private String password;

    /**
     * 昵称
     */
    @Length(groups = InsertAndUpdateGroups.class,
            min = 0,
            max = 128,
            message =  "昵称"+ MessageConstant.LENGTH_MESSAGE_128)
    private String nickName;

    /**
     * 性别 0 男  1女
     */
    @TableField(value = "gender",fill = FieldFill.INSERT)
    @Max(groups = InsertAndUpdateGroups.class,
            value = 1,
            message = "性别"+MessageConstant.FORMAT_MESSAGE)
    @Min(groups = InsertAndUpdateGroups.class,
            value = 0,
            message = "性别"+MessageConstant.FORMAT_MESSAGE)
    private Short gender;


    /**
     * 0：不在线  1：已上线
     */
    private Integer onLine;
    /**
     * 加密盐
     */

    private String salt;

    /**
     * 手机号
     */
    @NotNull(groups = InsertAndUpdateGroups.class,
            message = "手机号"+ MessageConstant.NULL_MESSAGE)
    @Length(groups = InsertAndUpdateGroups.class,
            min = 11,
            max = 11,
            message = "手机号"+MessageConstant.LENGTH_MESSAGE_11)
    @Pattern(groups = InsertAndUpdateGroups.class,
            regexp = RegularConstant.phone,
            message = MessageConstant.FORMAT_MESSAGE+"手机号")
    private String phone;

    /**
     * 头像
     */
    private String headUrl;


    /**
     * 邮箱（二期新增）
     */
    @Pattern(groups = InsertAndUpdateGroups.class,
            regexp = RegularConstant.mail,
            message = MessageConstant.FORMAT_MESSAGE+"邮箱")
    private String mail;

    /**
     * 用户状态 0可用 1停用（二期新增）
     */
    @TableField(value = "is_enable",fill = FieldFill.INSERT)
    @Max(groups = InsertAndUpdateGroups.class,
            value = 1,
            message = "用户状态"+MessageConstant.FORMAT_MESSAGE)
    @Min(groups = InsertAndUpdateGroups.class,
            value = 0,
            message = "用户状态"+MessageConstant.FORMAT_MESSAGE)
    private Short isEnable;



}
